package com.weixin.Controller;

import com.weixin.bean.AccessToken;
import com.weixin.utils.WeiXinUtil;
import org.slf4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;

/**
 * Created by Administrator on 2018-01-16.
 */
@Controller
@RequestMapping("/accessToken")
public class AccessTokenController {

    public AccessToken getAccessToken(){
        AccessToken token = null ;
        try {
            token = WeiXinUtil.getAccessToken();
            System.out.println("AccessToken为：" + token.getToken());
            System.out.println("有效时间为：" + token.getExpiresIn());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return token ;
    }
}
